# 批量修复商品页面中的路径问题
$goodsDir = "d:\meiduo_project\front_end_pc\goods"
$files = Get-ChildItem -Path $goodsDir -Filter "*.html"

foreach ($file in $files) {
    $content = Get-Content -Path $file.FullName -Raw -Encoding UTF8
    
    # 替换CSS和JS文件路径
    $content = $content -replace 'href="http://www.meiduo.site:8080/css/', 'href="../css/'
    $content = $content -replace 'src="http://www.meiduo.site:8080/js/', 'src="../js/'
    
    # 替换页面链接路径
    $content = $content -replace 'href="/login.html"', 'href="../login.html"'
    $content = $content -replace 'href="/register.html"', 'href="../register.html"'
    $content = $content -replace 'href="/user_center_info.html"', 'href="../user_center_info.html"'
    $content = $content -replace 'href="/cart.html"', 'href="../cart.html"'
    $content = $content -replace 'href="/user_center_order.html"', 'href="../user_center_order.html"'
    $content = $content -replace 'href="/index.html"', 'href="../index.html"'
    $content = $content -replace 'action="/search.html"', 'action="../search.html"'
    
    # 替换图片路径
    $content = $content -replace 'src="/images/', 'src="../images/'
    
    # 保存修改后的内容
    Set-Content -Path $file.FullName -Value $content -Encoding UTF8
    Write-Host "Fixed: $($file.Name)"
}

Write-Host "All goods pages have been fixed!"